package org.erp.procurement.entity;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.StringUtils;
import org.erp.common.basic.BaseEntity;

import java.util.Collections;

/**
 * 产品质检报告信息表
 *
 * @author libin
 * @version 1.0
 * @description: 产品质检报告信息表
 * @date 2025/11/6 11:32
 **/
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(value = "product_report", autoResultMap = true)
public class ProductReport extends BaseEntity {
    /**
     * 自增id
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 产品id
     */
    private Long productId;
    /**
     * 图片路径
     */
    private String imageUrls;
    /**
     * 瑕疵图片路径
     */
    private String flawImageUrls;
    /**
     * 质检报告信息
     */
    private String report;

    public static ProductReport addOneBuild(Long productId, String report) {
        return ProductReport.builder()
                .productId(productId)
                .imageUrls(JSONObject.toJSONString(Collections.EMPTY_LIST))
                .flawImageUrls(JSONObject.toJSONString(Collections.EMPTY_LIST))
                .report(StringUtils.isNotBlank(report) ? report : JSONObject.toJSONString(Collections.EMPTY_MAP))
                .build();
    }
}
